/*
Game: Revenge of the Olive: The Final Chapter

File: andre.js

Description:

Manipulation of display board, environment types and effects on player/enemy.
*/

function StatsDisplay()
{
	//display logo
	var logo = new PIXI.Sprite(getTexture("logo"));
	logo.setInteractive(false);
	logo.position.x = parseInt(window.innerWidth/2);
	logo.position.y = 32;
	logo.scale.x = 1.0;
	logo.scale.y =  1.0;
	stage.addChild(logo);
	
	//icon boxes
	var icons = new Array();
	for(i=0;i<5;i++)
	{
		icons[i] = new PIXI.Sprite(getTexture("iconbox"));
		icons[i].setInteractive(false);
		icons[i].position.x = (window.innerWidth/2)+(48*(i*2));
		icons[i].position.y = 400;
		icons[i].scale.x = 11.0;
		icons[i].scale.y = 11.0;
		stage.addChild(icons[i]);
	}
	
	var characters = new Array();
	//sets the icons  - default resets everything
	this.setIcon = function (option) {
	    switch (option) {
	        case 1:
	            break;
	        case 2:
	            break;
	        case 3:
	            break;
	        case 4:
	            break;
	        case 5:
	            break;
	        default:
	            for (i = 0; i < 5; i++) {
	                CreateTemplate((window.innerWidth / 2) + (48 * (i * 2)), 400, stage, i);
	            }
	    }
	}
	
	//text box descriptions
	var description = new PIXI.Sprite(getTexture("iconbox"));
	description.setInteractive(false);
	description.position.x = window.innerWidth/2;
	description.position.y = 512;
	description.scale.x = 75.0;
	description.scale.y = 20.0;
	stage.addChild(description);
	
	//setup text to display
	var textline1 = new PIXI.Text("", "20px Arial", "black");
	var textline2 = new PIXI.Text("", "14px Arial", "black");
	var textline3 = new PIXI.Text("", "14px Arial", "black");
	var textline4 = new PIXI.Text("", "14px Arial", "black");
	
	textline1.anchor.x = 0;
	textline1.position.x = description.position.x+16;
	textline1.position.y = 528;
	textline2.anchor.x = 0;
	textline2.position.x = description.position.x+16;
	textline2.position.y = 564;
	textline3.anchor.x = 0;
	textline3.position.x = description.position.x+16;
	textline3.position.y = textline2.position.y + 32;
	textline4.anchor.x =0;
	textline4.position.x = description.position.x + 16;
	textline4.position.y = textline3.position.y +32;

	stage.addChild(textline1);
	stage.addChild(textline2);
	stage.addChild(textline3);
	stage.addChild(textline4);
	
	//used to display text below - set be default
	this.displayText = function(option)
	{
		switch(option)
		{
			case 1:
				break;
			case 2:
				break;
			case 3:
				break;
			case 4:
				break;
			case 5:
				break;
			default:
				textline1.setText("The bunnies are coming!!!");
				textline2.setText("Defend yourself and your sanity!!!  We were bored so give us a break....");
				textline3.setText("");
				textline4.setText("");
				break;
		}
	}
	
}


//health bar
function HealthBar()
{
	var outside_box = new PIXI.Sprite(getTexture("outerbox"));
	var inside_box = new PIXI.Sprite(getTexture("innerbox"));
	var healthbox = new PIXI.Sprite(getTexture("healthbar"));
		
	//displays everything about the health bar
	this.display = function()
	{
		outside_box.setInteractive(false);
		inside_box.setInteractive(false);
		healthbox.setInteractive(false);
		
		outside_box.position.x = 32;
		outside_box.position.y = 512;
		outside_box.scale.x = ((parseInt(window.innerWidth/2)-64)/8); 
		outside_box.scale.y = 8.0;
		
		inside_box.position.x = outside_box.position.x + 8;
		inside_box.position.y = 520;
		inside_box.scale.x = ((parseInt(window.innerWidth/2)-80)/8);
		inside_box.scale.y = 6.0;
		
		healthbox.position.x = inside_box.position.x;
		healthbox.position.y = inside_box.position.y;
		healthbox.scale.x = inside_box.scale.x;
		healthbox.scale.y = inside_box.scale.y;
		
		stage.addChild(outside_box);
		stage.addChild(inside_box);
		stage.addChild(healthbox);
	}
	
	//updates the health bar 
	this.increment = function(amount) 
	{ 
		if(healthbox.scale.x < inside_box.scale.x)
			healthbox.scale.x += (0.375 * amount);
		else
			healthbox.scale.x = inside_box.scale.x;
	}
	
	//decreases the health bar
	this.decrement = function(amount) 
	{
		if(healthbox.scale.x >=0)
			healthbox.scale.x -= (0.375 * amount);
		else
			healthbox.scale.x = 0;
	}
	
	//resets the health bar
	this.resetbar = function() 
	{
		healthbox.scale.x = inside_box.scale.x;
	}
	
	//experimental feature....ignore
	this.updatebar = function() 
	{
		count += 0.005
		healthbox.tileScale.x = 2 + Math.sin(count);
		healthbox.tileScale.y = 2 + Math.cos(count);

		healthbox.tilePosition.x += 1;
		healthbox.tilePosition.y += 1;		
	}
}


























/*
//global variables
var stage_left = new PIXI.Stage(0x97c56e, true);	//board area  
var stage_right = new PIXI.Stage(0x567837, true);	//player selection area
var render_left = PIXI.autoDetectRenderer(window.innerWidth/2, window.innerHeight, null);
var render_right = PIXI.autoDetectRenderer(window.innerWidth/2, window.innerHeight, null);
var STAGE_LEFT_POSITION = "0px";
var STAGE_RIGHT_POSITION = parseInt(window.innerWidth/2)+"px";

//render stages left and right
function renderStage()
{
	// add the renderer view element to the DOM
	document.body.appendChild(render_left.view);
	render_left.view.style.position = "absolute";
	render_left.view.style.top = "0px";
	render_left.view.style.left = "0px";	
	
	document.body.appendChild(render_right.view);
	render_right.view.style.position = "absolute";
	render_right.view.style.top = "0px";
	render_right.view.style.left = parseInt(window.innerWidth/2)+"px";
	
	requestAnimFrame(animate);

	// create a background..
	var background = PIXI.Sprite.fromImage("grid.png");
	background.position.x = background.position.y = 64;
	// add background to stage..
	stage_left.addChild(background);
}

/*
addPixiElement = function(){
    renderer  = new PIXI.WebGLRenderer(window.innerWidth/2, window.innerHeight)
    pixiStage = new PIXI.Stage(0xFF0000)
    
    document.body.appendChild( renderer.view )
    renderer.render( pixiStage )
}
*/